﻿#include "OperActionSpectrogramResult.h"

#include "GUIFrame/MainWindow.h"
#include "GUIFrame/CentralWidget.h"
#include "GUIWidget/PreWindow3D.h"
#include "OperatorsInterface/GraphPostEventOperator.h"
#include "GUIDialog/GUIPostDialog/GUIContourPlotDialog.h"

#include "FITK_Kernel/FITKCore/FITKAbstractDataManager.hpp"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKAppFramework/FITKMessage.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsDiscModel.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsSEAModel.h"
#include "FITK_Component/FITKAcousticsModel/FITKAbstractSEASubSys.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsAbstractSpectra.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraPressure.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraVelocity.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKSpectraAlgorithm.h"
#include "FITK_Component/FITKAcousticsPostData/FITKAcousticsPostData.h"
#include "FITK_Component/FITKAcousticsPostData/FITKAcousticsContourPlotData.h"
#include "FITK_Component/FITKAcousticsPostData/FITKAcousticsHDF5AttributeObject.hpp"
#include "FITK_Component/FITKAcousticsPostData/FITKAcousticsHDF5Constants.h"
#include "FITK_Component/FITKAcousticsPostData/FITKAcousticsHDF5DataSet.hpp"
#include "FITK_Component/FITKAcousticsPostData/FITKAcousticsHDF5Frequencies.h"
#include "FITK_Component/FITKAcousticsPostData/FITKAcousticsHDF5LoadCase.h"

#include <qmath.h>

bool GUIOper::OperActionSpectrogramResult::execGUI()
{

    auto widget3D = getPerWindow3D();
    if (nullptr == widget3D) return false;
    GUI::GUIContourPlotDialog* dlg = new GUI::GUIContourPlotDialog(widget3D);

    //初始化界面数据
    Acoustics::FITKAcousticsPostData* postData = FITKAPP->getGlobalData()->getPostData<Acoustics::FITKAcousticsPostData>();
    if (nullptr == postData) return false;
    dlg->setListHz(getFrequenciesData(postData));//加载频率数据
    dlg->setListLoadCases(getLoadCases(postData));//加载工况数据

    Acoustics::FITKAcousticsContourPlotData* plotData = getContourPlotData();
    if (nullptr == plotData) return false;
    dlg->setPlotData(plotData);//加载界面设置参数
    dlg->init();

    connect(dlg, &QDialog::accepted, this, &OperActionSpectrogramResult::dialogAccepted_Slot);
    connect(dlg, &GUI::GUIContourPlotDialog::dialogApplySignal, this, &OperActionSpectrogramResult::dialogAccepted_Slot);
    //显示界面
    dlg->show();

    return false;
}

bool GUIOper::OperActionSpectrogramResult::execProfession()
{
    //临时
    return false;
}

std::vector<float> GUIOper::OperActionSpectrogramResult::getFrequenciesData(Acoustics::FITKAcousticsPostData* postData)
{
    std::vector<float> vecData;

    if (nullptr == postData) return vecData;
    //获取后处理常数集数据
    Acoustics::FITKAcousticsHDF5Constants* constants = postData->getFITKAcousticsHDF5Constants();
    if (nullptr == constants) return vecData;
    //获取后处理频率数据
    Acoustics::FITKAcousticsHDF5Frequencies* frequencies = constants->getFITKAcousticsHDF5Frequencies();
    if (nullptr == frequencies) return vecData;
    //获取频率数据集
    Acoustics::FITKAcousticsHDF5DataSetManager* dataSetManager = frequencies->getFITKAcousticsHDF5DataSetManager();
    if (nullptr == dataSetManager) return vecData;
    if (dataSetManager->getDataCount() <= 0) return vecData;
    //获取频率第一个数据对象
    Acoustics::FITKAcousticsHDF5DataSet* dataSet = dataSetManager->getDataByIndex(0);
    if (nullptr == dataSet) return vecData;
    QHash<int, std::vector<float>> hashValue = dataSet->getValues();
    if (hashValue.size() <= 0) return vecData;
    vecData = hashValue.value(hashValue.keys().first());
    return vecData;
}

QStringList GUIOper::OperActionSpectrogramResult::getLoadCases(Acoustics::FITKAcousticsPostData* postData)
{
    QStringList list;
    if (nullptr == postData) return list;
    //获取工况载荷数据集
    Acoustics::FITKAcousticsHDF5LoadCaseManager* loadCaseManager = postData->getFITKAcousticsHDF5LoadCaseManager();
    if (nullptr == loadCaseManager) return list;

    int count = loadCaseManager->getDataCount();
    for (int i = 0; i < count; i++)
    {
        //遍历所有工况根据索引
        auto loadCase = loadCaseManager->getDataByIndex(i);
        if (nullptr == loadCase) continue;
        //获取工况名称
        list.append(loadCase->getDataObjectName());
    }
    return list;
}

QList<Acoustics::FITKAbstractSEASubSys*> GUIOper::OperActionSpectrogramResult::getSEASubSysByType(Acoustics::FITKAcousticsContourPlotData* plotData)
{
    QList<Acoustics::FITKAbstractSEASubSys*> list;
    //获取离散数据
    Acoustics::FITKAcousticsDiscModel* discModel = FITKAPP->getGlobalData()->getMeshData<Acoustics::FITKAcousticsDiscModel>();
    if (!discModel)return list;
    //获取SEA点数据
    Acoustics::FITKAcousticsSEAModel* seaModel = discModel->getSEAModel();
    if (!seaModel) return list;
    //获取数据管理器
    Acoustics::FITKAcousticsSEASubSysManager *dataManager = seaModel->getSEASubSysManager();
    if (!dataManager)return list;
    if (!plotData) return list;

    auto engUnitsType = plotData->getSelectedEngUnitsType();//获取显示类型

    int count = dataManager->getDataCount();
    for (int i = 0; i < count; i++)
    {
        Acoustics::FITKAbstractSEASubSys* subSys = dataManager->getDataByIndex(i);
        if (!subSys) continue;
        //根据类型 获取  可视化显示对象名称
        if (engUnitsType == Acoustics::FITKAcousticsContourPlotData::EngUnitsType::Pressure
            && subSys->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEACavity)  //声压 -> 声腔
        {
            //获取所有声腔名称集合
            list.append(subSys);
        }
        else if (engUnitsType == Acoustics::FITKAcousticsContourPlotData::EngUnitsType::Velocity) //速度 -> 梁 和 板 壳
        {
            if (subSys->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEABeam ||
                subSys->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEAFlatPlate ||
                subSys->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEADoublyCurvedShell ||
                subSys->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEASinglyCurvedShell ||
                subSys->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEACylinderShell)
            {
                //获取所有SEA板及梁名称集合
                list.append(subSys);
            }
        }
    }

    return list;
}

Acoustics::FITKAcousticsContourPlotData* GUIOper::OperActionSpectrogramResult::getContourPlotData()
{

    Acoustics::FITKAcousticsPostData* postData = FITKAPP->getGlobalData()->getPostData<Acoustics::FITKAcousticsPostData>();
    if (nullptr == postData) return nullptr;

    auto contourPlotManager = postData->getContourPlotDataManager();
    if (nullptr == contourPlotManager) return nullptr;

    QString widget3DName = getWidgetName();
    Acoustics::FITKAcousticsContourPlotData* plotData = dynamic_cast<Acoustics::FITKAcousticsContourPlotData*>(contourPlotManager->getDataByName(widget3DName));

    if (nullptr == plotData)
    {
        plotData = new Acoustics::FITKAcousticsContourPlotData();
        plotData->setDataObjectName(widget3DName);
        contourPlotManager->appendDataObj(plotData);
    }

    return plotData;
}

QString GUIOper::OperActionSpectrogramResult::getWidgetName()
{
    GUI::PreWindow3D* widget3D = getPerWindow3D();
    if (widget3D == nullptr) return QString();
    QString widget3DName = QString("widget3D_%1").arg(widget3D->getGUIObjectID());
    return widget3DName;
}

GUI::PreWindow3D* GUIOper::OperActionSpectrogramResult::getPerWindow3D()
{
    GUI::MainWindow * mainWindow = dynamic_cast<GUI::MainWindow *>(FITKAPP->getGlobalData()->getMainWindow());
    if (!mainWindow || !_emitter)return nullptr;

    //获取当前激活的3D窗口 名称
    GUI::PreWindow3D* widget3D = mainWindow->getCentralWidget()->getGraphArea()->getCurrentWindow<GUI::PreWindow3D>();
    return widget3D;
}

QHash<QString, float> GUIOper::OperActionSpectrogramResult::getRawDatas()
{
    QHash<QString, float> hashData;
    auto plotData = getContourPlotData();//获取界面参数对象
    if (nullptr == plotData) return hashData;

    //根据显示类型获取 名称集合 
    auto listSEASubSys = getSEASubSysByType(plotData);

    Acoustics::FITKAcousticsPostData* postData = FITKAPP->getGlobalData()->getPostData<Acoustics::FITKAcousticsPostData>();
    if (nullptr == postData) return hashData;
    auto loadCaseManager = postData->getFITKAcousticsHDF5LoadCaseManager();
    if (!loadCaseManager) return hashData;
    QString loadCaseName = plotData->getSelectedLoadCase();//获取选择工况载荷名称
    auto selectLoadCase = loadCaseManager->getDataByName(loadCaseName);
    if (!selectLoadCase) return hashData;
    auto loadCaseChildManager = selectLoadCase->getFITKAcousticsHDF5ObjectChildManager();//获取工况下子集
    if (!loadCaseChildManager) return hashData;
    auto subSystems = loadCaseChildManager->getDataByName("SubSystems");//获取子系统节点
    if (!subSystems) return hashData;
    auto subSystemManager = subSystems->getFITKAcousticsHDF5ObjectChildManager();//获取子系统子节点管理器
    if (!subSystemManager) return hashData;
    int count = listSEASubSys.size();
    for (int i = 0; i < count; i++)
    {
        auto itemSEASubSys = listSEASubSys.at(i);//获取Model中存的子系统对象
        if (!itemSEASubSys) continue;
        QString subSysName = itemSEASubSys->getDataObjectName();//获取名称
        auto subSysPostItem = subSystemManager->getDataByName(subSysName);//根据名称 获取 后处理数据中的对应数据对象
        if (!subSysPostItem) continue;
        auto dataSetManager = subSysPostItem->getFITKAcousticsHDF5DataSetManager();//获取该对象的DataSet数据集集合
        if (!dataSetManager) continue;
        float f = getValueBySetting(plotData, dataSetManager, itemSEASubSys);
        hashData.insert(subSysName, f);
    }

    return hashData;
}

float GUIOper::OperActionSpectrogramResult::mathSumValue(QList<float> list)
{
    float fResult = .0f;

    for (float f : list)
    {
        fResult += qPow(f, 2);
    }

    fResult = qSqrt(fResult);

    return fResult;
}

float GUIOper::OperActionSpectrogramResult::getValueBySetting(
    Acoustics::FITKAcousticsContourPlotData* plotData,
    Acoustics::FITKAcousticsHDF5DataSetManager* dataSetManager,
    Acoustics::FITKAbstractSEASubSys* subSysItem)
{
    float fResult = .0f;
    if (!plotData) return fResult;
    QString engUnitsType = plotData->getSelectedEngUnitsType();
    if (engUnitsType == Acoustics::FITKAcousticsContourPlotData::EngUnitsType::Pressure)
    {
        fResult = getValueFromSEACavity(plotData, dataSetManager);//从声腔中获取数据
    }
    else if (engUnitsType == Acoustics::FITKAcousticsContourPlotData::EngUnitsType::Velocity)
    {
        if (!subSysItem) return fResult;
        if (subSysItem->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEABeam)
        {
            fResult = getValueFromSEABeam(plotData, dataSetManager, subSysItem->getDataObjectName());//从梁类型中获取数据
        }
        else if (subSysItem->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEAFlatPlate ||
            subSysItem->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEADoublyCurvedShell ||
            subSysItem->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEASinglyCurvedShell ||
            subSysItem->getSEASubSysType() == Acoustics::FITKAbstractSEASubSys::SEACylinderShell)
        {
            fResult = getValueFromSEAPlateOrShell(plotData, dataSetManager, subSysItem->getDataObjectName());//从SEA板中获取数据
        }
    }
    return fResult;
}

float GUIOper::OperActionSpectrogramResult::getValueFromSEACavity(Acoustics::FITKAcousticsContourPlotData* plotData, Acoustics::FITKAcousticsHDF5DataSetManager* dataSetManager)
{
    float fResult = .0f;
    if (!plotData) return fResult;
    if (!dataSetManager) return fResult;
    //取数据集
    if (dataSetManager->getDataCount() == 0) return fResult;
    auto dataSet = dataSetManager->getDataByIndex(0);//默认取第一个数据集
    if (!dataSet) return fResult;
    //取数据集中的数据列集
    auto hashValue = dataSet->getValues();
    if (hashValue.size() == 0) return fResult;
    //取数据列集中的第一列数据
    auto vecFloat = hashValue.value(hashValue.keys().first());//默认只有一列数据
    int hzIndex = plotData->getSelectedHzIndex();
    //根据频率索引取该频率数值
    if (vecFloat.size() < hzIndex) return fResult;
    fResult = vecFloat.at(hzIndex);
    return fResult;
}

float GUIOper::OperActionSpectrogramResult::getValueFromSEAPlateOrShell(
    Acoustics::FITKAcousticsContourPlotData* plotData,
    Acoustics::FITKAcousticsHDF5DataSetManager* dataSetManager,
    QString subSysName)
{
    float fResult = .0f;
    if (!plotData) return fResult;
    if (!dataSetManager) return fResult;
    if (dataSetManager->getDataCount() == 0) return fResult;

    QList<Acoustics::FITKAcousticsHDF5DataSet*> listTmpDataSet;
    //根据界面选中的状态，提取数据
    if (plotData->getTransverse_Flexure())
    {
        QString dataSetName = QString("%1F").arg(subSysName);
        auto dataSet = dataSetManager->getDataByName(dataSetName);
        if (dataSet) listTmpDataSet.append(dataSet);
    }
    if (plotData->getIn_plane_Extension())
    {
        QString dataSetName = QString("%1E").arg(subSysName);
        auto dataSet = dataSetManager->getDataByName(dataSetName);
        if (dataSet) listTmpDataSet.append(dataSet);
    }
    if (plotData->getIn_plane_Shear())
    {
        QString dataSetName = QString("%1S").arg(subSysName);
        auto dataSet = dataSetManager->getDataByName(dataSetName);
        if (dataSet) listTmpDataSet.append(dataSet);
    }

    int hzIndex = plotData->getSelectedHzIndex();
    QList<float> listFloatData = getValueByDataSetList(listTmpDataSet, hzIndex);//根据频率和数据集获取有效数据
    fResult = mathSumValue(listFloatData);//将数据进行拟合
    return fResult;
}

float GUIOper::OperActionSpectrogramResult::getValueFromSEABeam(
    Acoustics::FITKAcousticsContourPlotData* plotData,
    Acoustics::FITKAcousticsHDF5DataSetManager* dataSetManager,
    QString subSysName)
{
    float fResult = .0f;
    if (!plotData) return fResult;
    if (!dataSetManager) return fResult;
    if (dataSetManager->getDataCount() == 0) return fResult;

    QList<Acoustics::FITKAcousticsHDF5DataSet*> listTmpDataSet;
    //根据界面选中的状态，提取数据
    if (plotData->getBeams_Flexure_X())
    {
        QString dataSetName = QString("%1X").arg(subSysName);
        auto dataSet = dataSetManager->getDataByName(dataSetName);
        if (dataSet) listTmpDataSet.append(dataSet);
    }
    if (plotData->getBeams_Flexure_Y())
    {
        QString dataSetName = QString("%1Y").arg(subSysName);
        auto dataSet = dataSetManager->getDataByName(dataSetName);
        if (dataSet) listTmpDataSet.append(dataSet);
    }
    if (plotData->getBeams_Extension())
    {
        QString dataSetName = QString("%1E").arg(subSysName);
        auto dataSet = dataSetManager->getDataByName(dataSetName);
        if (dataSet) listTmpDataSet.append(dataSet);
    }
    //
    if (plotData->getBeams_Torsion())
    {
        QString dataSetName = QString("%1T").arg(subSysName);
        auto dataSet = dataSetManager->getDataByName(dataSetName);
        if (dataSet) listTmpDataSet.append(dataSet);
    }

    int hzIndex = plotData->getSelectedHzIndex();
    QList<float> listFloatData = getValueByDataSetList(listTmpDataSet, hzIndex);//根据频率和数据集获取有效数据
    fResult = mathSumValue(listFloatData);//将数据进行拟合
    return fResult;
}

QList<float> GUIOper::OperActionSpectrogramResult::getValueByDataSetList(
    QList<Acoustics::FITKAcousticsHDF5DataSet*> listDataSet, int hzIndex)
{
    QList<float> listFloatData;
    for (auto dataSet : listDataSet)
    {
        if (!dataSet) continue;
        auto hashValue = dataSet->getValues();
        if (hashValue.size() == 0)  continue;
        auto vecFloat = hashValue.value(hashValue.keys().first());//默认只有一列数据
        if (vecFloat.size() < hzIndex) continue;
        listFloatData << vecFloat.at(hzIndex);
    }
    return listFloatData;
}

QHash<QString, float> GUIOper::OperActionSpectrogramResult::mathValueByPlotSetting(QHash<QString, float> hashRawData, Acoustics::FITKAcousticsContourPlotData* plotData)
{
    QHash<QString, float> hashResult;
    if (!plotData) return hashResult;
    bool b = true;
    double dHz = plotData->getSelectedHzName().toDouble(&b);
    if (!b) return hashResult;

    //组织原始计算数据
    QList<QString> rawKeys = hashRawData.keys();
    QList<Acoustics::SpectraValue> listSpectra;
    for (QString rawKey : rawKeys)
    {
        Acoustics::SpectraValue item;
        item._hz = dHz;
        Core::FITKNumberComplex value;
        value.setReal(double(hashRawData.value(rawKey)));
        item._value = value;
        listSpectra << item;
    }

    if (plotData->getSelectedEngUnitsType() == Acoustics::FITKAcousticsContourPlotData::EngUnitsType::Pressure)
    {
        //声压类型
        Acoustics::FITKSpectraPressure loadPressure;
        Acoustics::FITKSpectraAlgorithm* spectraAlg = loadPressure.getSpectraAlg();
        //DB处理
        if (plotData->getPressure_DB() == true && spectraAlg)
        {
            spectraAlg->setDBAlgConfig(true, plotData->getPressure_Ref());
            spectraAlg->calcDBData(true, listSpectra);
            listSpectra = spectraAlg->getResults();
            //A计权处理
            if (plotData->getPressure_AWeighting() == true)
            {
                //A权计算
                spectraAlg->setAWeighting(true);
                spectraAlg->calcAWeighting(true, listSpectra, 1);
                listSpectra = spectraAlg->getResults();
            }
        }
    }
    else if (plotData->getSelectedEngUnitsType() == Acoustics::FITKAcousticsContourPlotData::EngUnitsType::Velocity)
    {
        //速度类型 速度仅处理DB
        Acoustics::FITKSpectraVelocity loadVelocity;
        Acoustics::FITKSpectraAlgorithm* spectraAlg = loadVelocity.getSpectraAlg();
        //DB处理
        if (plotData->getPressure_DB() == true && spectraAlg)
        {
            spectraAlg->setDBAlgConfig(true, plotData->getVelocity_Ref());
            spectraAlg->calcDBData(true, listSpectra);
            listSpectra = spectraAlg->getResults();
        }
    }
    if (listSpectra.size() != rawKeys.size()) return hashResult;
    int count = listSpectra.size();
    //按顺序将数据进行装配
    for (int i = 0; i < count; i++)
    {
        QString key = rawKeys.at(i);
        float fValue = float(listSpectra.at(i)._value.getReal());
        if (isinf(fValue)) fValue = 0.0f;
        hashResult.insert(key, fValue);
    }

    return hashResult;
}

QString GUIOper::OperActionSpectrogramResult::createBarName()
{
    QString str;
    auto plotData = getContourPlotData();
    if (!plotData) return str;
    str.append(QString("%1 Hz\n").arg(plotData->getSelectedHzName()));
    str.append(QString("%1 %2 %3\n").arg(plotData->getSelectEngUnitsTypeName()).arg("Magnitude").arg("RMS"));//临时
    if (plotData->getSelectedEngUnitsType() == Acoustics::FITKAcousticsContourPlotData::Pressure)
    {
        if (plotData->getPressure_AWeighting())
        {
            str.append(QString("dBA\n"));
            str.append(QString("ref=%1 Pa").arg(plotData->getPressure_Ref()));
        }
        else if (plotData->getPressure_DB())
        {
            str.append(QString("dB\n"));
            str.append(QString("ref=%1 Pa").arg(plotData->getPressure_Ref()));
        }
        else
        {
            str.append(QString("Pa"));
        }
    }
    else if (plotData->getSelectedEngUnitsType() == Acoustics::FITKAcousticsContourPlotData::Velocity)
    {
        if (plotData->getVelocity_DB())
        {
            str.append(QString("dB\n"));
            str.append(QString("ref=%1 Pa").arg(plotData->getVelocity_Ref()));
        }
        else
        {
            str.append(QString("m/s"));
        }
    }
    return str;
}

void GUIOper::OperActionSpectrogramResult::updateScaleData(Acoustics::FITKAcousticsContourPlotData* plotData, GUI::GUIContourPlotDialog* dlg, float& fMin, float fMax)
{
    if (!plotData) return;
    if (plotData->getSelectedEngUnitsType() == Acoustics::FITKAcousticsContourPlotData::EngUnitsType::Velocity)
    {
        //速度类型
        if (plotData->getVelocity_Autoscale())
        {
            //若选择自动则 使用计算数据上下限
            plotData->setVelocity_Max(double(fMax));
            plotData->setVelocity_Min(double(fMin));
            if (!dlg) return;
            dlg->updateScaleState();//界面刷新数据
        }
        else
        {
            //非自动使用设置值
            fMax = plotData->getVelocity_Max();
            fMin = plotData->getVelocity_Min();
        }
    }
    else if (plotData->getSelectedEngUnitsType() == Acoustics::FITKAcousticsContourPlotData::EngUnitsType::Pressure)
    {
        //声压类型
        if (plotData->getPressure_Autoscale())
        {
            //若选择自动则 使用计算数据上下限
            plotData->setPressure_Max(double(fMax));
            plotData->setPressure_Min(double(fMin));
            if (!dlg) return;
            dlg->updateScaleState();//界面刷新数据
        }
        else
        {
            //非自动使用设置值
            fMax = plotData->getPressure_Max();
            fMin = plotData->getPressure_Min();
        }
    }
}

bool GUIOper::OperActionSpectrogramResult::isUseLogSetting(Acoustics::FITKAcousticsContourPlotData* plotData)
{
    if (!plotData) return false;
    if (plotData->getSelectedEngUnitsType() == Acoustics::FITKAcousticsContourPlotData::Pressure
        && !plotData->getPressure_DB() && plotData->getPressure_IsLog())
    {
        //声压状态下 未选中DB模式 且选择了Log显示
        return true;
    }
    if (plotData->getSelectedEngUnitsType() == Acoustics::FITKAcousticsContourPlotData::Velocity
        && !plotData->getVelocity_DB() && plotData->getVelocity_IsLog())
    {
        return true;
    }
    return false;

}

void GUIOper::OperActionSpectrogramResult::dialogAccepted_Slot()
{
    GUI::GUIContourPlotDialog* dlg = dynamic_cast<GUI::GUIContourPlotDialog*>(sender());
    if (nullptr == dlg) return;
    //算法计算后的数据 传递给 GraphPostEventOperator
    EventOper::GraphPostEventOperator* postOper = Core::FITKOperatorRepo::getInstance()->
        getOperatorT<EventOper::GraphPostEventOperator>("GraphPost");
    if (!postOper) return;

    auto plotData = getContourPlotData();
    if (nullptr == plotData) return;

    if (!plotData->getDisplay())
    {
        //取消后处理模式
        postOper->disablePostData();
        return;
    }
    //通过 界面参数设定 获取 可用的原始数据
    QHash<QString, float> hashRawData = getRawDatas();

    //处理 DB 与A计权 数据处理
    QHash<QString, float> hashMathData = mathValueByPlotSetting(hashRawData, plotData);

    //计算最大小值
    QList<float> listMathData = hashMathData.values();
    float fMax = -1.0e33f, fMin = 1.0e33f;
    for (float f : listMathData)
    {
        fMax = qMax(f, fMax);
        fMin = qMin(f, fMin);
    }
    //更新比例上下限
    updateScaleData(plotData, dlg, fMin, fMax);

    //设置Log显示模式
    postOper->setEnableLogScale(isUseLogSetting(plotData));

    //生成色棒的标题
    QString barName = createBarName();

    //传递数据
    postOper->updatePostData(hashMathData, barName, fMin, fMax);

}
